<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

/**
*
* @package MediaLibrary
* @copyright 2009 Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru);Rob de Cleen(rob@decleen.com)
* Homepage: http://www.joomlawebserver.com
* @version: 1.5.3 Basic $
*
**/


require_once($mosConfig_absolute_path."/libraries/joomla/plugin/helper.php");
require_once($mosConfig_absolute_path."/includes/HTML_toolbar.php");
require_once ($mosConfig_absolute_path."/components/com_medialibrary/medialibrary.php");
require_once($mosConfig_absolute_path."/administrator/components/com_medialibrary/menubar_ext.php");

$g_item_count = 0;

class HTML_medialibrary 
{


	function showLendRequest( & $medias, & $currentcat, & $params, & $tabclass, & $catid, & $sub_categories,$is_exist_sub_categories){

		HTML_medialibrary::displayMedias($medias, $currentcat, $params, $tabclass, $catid, $sub_categories, $is_exist_sub_categories);
		// add the formular for send to :-)
	}

	function displayMedias(&$rows, $currentcat, &$params, $tabclass, $catid, $categories,$is_exist_sub_categories)
  {

    global $hide_js, $Itemid,$mosConfig_live_site,$mosConfig_absolute_path;
    global $limit, $total, $limitstart, $task, $paginations, $mainframe;

    $mainframe->addCustomHeadTag('<script type="text/javascript" src= "'
      .$mosConfig_live_site.'/includes/js/mambojavascript.js"></script>');

		$mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="'
      .$mosConfig_live_site.'/includes/js/calendar/calendar-mos.css" title="green" />');

		$mainframe->addCustomHeadTag('<script type="text/javascript" src= "'
      .$mosConfig_live_site.'/includes/js/calendar/calendar.js">  </script>');
		$mainframe->addCustomHeadTag('<script type="text/javascript" src= "'
      .$mosConfig_live_site.'/includes/js/calendar/lang/calendar-en-GB.js"> </script>');

    $mainframe->addCustomHeadTag('<script type="text/javascript" src= "'
        .$mosConfig_live_site.'/includes/js/overlib_mini.js"></script>');

    $mainframe->addCustomHeadTag('<script type="text/javascript" src= "'
        .$mosConfig_live_site.'/includes/js/dhtml.js"> </script>');

    $mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="./administrator/components/com_medialibrary/includes/medialibrary.css" title="green" />');
?>
		
                <script type="text/javascript">
		function lend_request_submitbutton() {
			var form = document.userForm;
			if (form.user_name.value == "") {
				alert( "<?php echo _MEDIALIBRARY_INFOTEXT_JS_LEND_REQ_NAME; ?>" );				
			} else if (form.user_email.value == "" || !isValidEmail(form.user_email.value)) {
				alert( "<?php echo _MEDIALIBRARY_INFOTEXT_JS_LEND_REQ_EMAIL;?>" );
			} else if (form.user_mailing == "") {       
				alert( "<?php echo _MEDIALIBRARY_INFOTEXT_JS_LEND_REQ_MAILING;?>" );
			} else if ((form.lend_until.value == "") || (form.lend_until.value < form.lend_from.value)) {  
				alert( "<?php echo _MEDIALIBRARY_INFOTEXT_JS_LEND_REQ_UNTIL;?>" );
			} else {
				form.submit();
			}
		}
		
		function isValidEmail(str) {
			return (str.indexOf("@") > 1);
		}
		</script>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div>
		<table border="0" cellpadding="4" cellspacing="0" width="100%">
			<tr>				
				<?php
				if($currentcat->img != null && $currentcat->align == 'left' && $params->get( 'show_cat_pic') ){
				?>
				<td>
		        	  <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" alt="?"/>
		        	</td>
		        <?php
				}
				?>
				<td width="100%">
					<?php echo $currentcat->descrip; ?>
				</td>
		        <?php
					if($currentcat->img != null && $currentcat->align == 'right'){
				?>
				<td>
		        	  <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" alt="?" />
		        	</td>
		        <?php
				}
				?>
		     	</tr>
		   </table>
			<?php
			if ($params->get('show_lendstatus') && $params->get('show_lendrequest') 
          && !$params->get( 'lend_save'))
      { ?>
          <form action="<?php echo  sefRelToAbs("index.php?option=com_medialibrary&amp;task=lend_request&amp;Itemid=".$Itemid); ?>" method="post" name="userForm">								
			<?php
			} else if ($params->get('show_lendstatus') && $params->get('show_lendrequest') && $params->get( 'lend_save'))
      { ?>
        <form action="<?php echo sefRelToAbs("index.php?option=com_medialibrary&amp;task=save_lend_request&amp;Itemid=".$Itemid );?>"  method="post" name="userForm">
			<?php 
      } else 
      { ?>

        <form action="<?php echo sefRelToAbs("index.php?option=com_medialibrary&amp;Itemid=". $Itemid); ?>" method="post" name="userForm">

			<?php } ?>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
    $total = count($rows);
    if($limitstart<$total) {
?>
			<tr>
				<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo _MEDIALIBRARY_LABEL_COVER; ?>
				</td>
				<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo _MEDIALIBRARY_LABEL_TITLE; ?>
				</td>
				<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?>
				</td>
				<?php
				if ( $params->get( 'show_rating' ) ) {
					?>
					<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
						<?php echo _MEDIALIBRARY_LABEL_RATING; ?>
					</td>
				<?php
				} 				
				if ( $params->get( 'hits' ) ) {
					?>
					<td width="30" height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>" align="right">
						<?php echo _MEDIALIBRARY_LABEL_HITS; ?>
					</td>
					<?php 
				}
				if ( $params->get( 'search_request' ) ) {
					?>
					<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>" align="right">
						<?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?>
					</td>
					<?php
				}
				if( $params->get('show_lendstatus')){
				?>
					<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">	
						<?php echo _MEDIALIBRARY_LABEL_LEND_CB; ?>
					</td>
				<?php
				}
				?>
			</tr>
		<?php 
    }
		$available = false;   
		$k = 0;
//****************************************   add my perenos

		for ($i=$limitstart; $i<($limit+$limitstart) and $i<$total; $i++) {
			
                    $row=$rows[$i];
//****************************************   add my perenos
			$link = 'index.php?option=com_medialibrary&amp;task=view&amp;id='. $row->id . '&amp;catid='. $row->catid .'&amp;Itemid='. $Itemid;     //
			?>			
			<tr class="<?php echo $tabclass[$k]; ?>" >
				<td style="padding-left:5px; padding-top:5px; padding-right:10px;">
         <?php
					$book = $row;
					if($book->URL != ''){
						echo '<a href="';
						echo $book->URL;
						echo '"  target="blank"></a>';
					}
					//for local images
					$imageURL = $book->imageURL;
					if($imageURL != '' && substr($imageURL,0,4) != "http")
					{
						$imageURL = $mosConfig_live_site . '/'. $book->imageURL;;
					}
					if($imageURL != ''){
						echo '<img src="';
						echo $imageURL;
						echo '" alt="cover" border="0" height="50" />&nbsp;';
					} else{
						echo '<img src="./components/com_medialibrary/images/';
						echo _MEDIALIBRARY_NO_PICTURE;    
						echo '" alt="no-img_eng.gif" border="0" />&nbsp;';
					}?>
				</td>
				<td  width="45%">
				<a href="<?php echo sefRelToAbs( $link ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<?php echo $row->title; ?> 
				</a> 
				<!--<?php 
				if ( $params->get( 'item_description' ) ) {
					?>
					<br /> 
					<?php echo $row->description; ?>
					<?php 
				} 
				?>-->
				</td>
				<td  width="55%"> 				
					<?php echo $row->media_type; ?> 
				</td>
				<?php
				if ( $params->get( 'show_rating' ) ) {
					?>
					<td align="right"> 				
						<img src="./components/com_medialibrary/images/rating-<?php echo $row->rating; ?>.gif" alt="<?php echo ($row->rating)/2; ?>" align="left" border="0" />&nbsp;&nbsp;
					</td>
				<?php
				}
				if ( $params->get( 'hits' ) ) {
					?>
					<td align="left">
					<?php echo $row->hits; ?>
					</td>
					<?php 
				} 
				if ( $params->get( 'search_request' ) ) {
					$link1 = 'index.php?option=com_medialibrary&amp;task=showCategory&amp;catid='. $row->catid .'&amp;Itemid='. $Itemid;
				?>
					<td align="right">
						<a href="<?php echo sefRelToAbs( $link1 ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
							<?php echo $row->category_titel; ?>
						</a>
					</td>
				<?php
				}
				if ($params->get('show_lendstatus')){ 
					if ($params->get('show_lendrequest')){?>
					<td align="left"> 
						<?php 
						if($row->fk_lendid == 0) {
							if($params->get( 'lend_save')){
							?>
								<input type="checkbox" id="cb<?php echo  $k; ?>" name="bid[]" value="<?php echo  $row->id; ?>" checked="checked" />
							<?php
								$available = true;  
							} else {
								//echo mosHTML::idBox( $k, $row->id, false, 'bid' );
							?>
								<input type="checkbox" id="cb<?php echo  $row->id; ?>" name="bid[]" value="<?php echo  $row->id; ?>" />
							<?php
								$available = true;   
							}
						} else {
							echo "<img src='./components/com_medialibrary/images/not_available.png' alt='Not Available' name='image' border='0' align='middle' />";
						}
						?>									
					</td>
				<?php
					} else {
						if ($row->fk_lendid != 0){ ?>
							<td>
								<img src="./components/com_medialibrary/images/not_available.png" alt="?" border="0" align="left"/>
							</td>
						<?php 
						} else { ?>
							<td>
								<img src="./components/com_medialibrary/images/available.png" alt="?" border="0" align="left"/>
							</td>
						<?php
						}
					}
				} ?>
			</tr>
			<?php
			$k = 1 - $k;
		} 
		?>
		<tr><td colspan="6" align="center">&nbsp;</td></tr>

		<tr>
			<td colspan="6" align="center">

<?php

			if ($paginations && ( $total > $limit ))
			{
				require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' );
				$pageNav = new mosPageNav( $total, $limitstart, $limit );
				$link = 'index.php?option=com_medialibrary&amp;task='. $task .'&amp;catid='. $catid .'&amp;Itemid='. $Itemid;
				echo $pageNav->writePagesLinks( sefRelToAbs( $link ) );
			}
?>

			</td>
		</tr>
	</table>

	
		<?php
		if ($params->get('show_lendstatus') && $params->get('show_lendrequest') && $params->get( 'lend_save') && $available){   
		?>

		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _MEDIALIBRARY_LABEL_LEND_INFORMATIONS; ?>
		</div>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">			
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>

			<tr>
				<td>
					<?php echo _MEDIALIBRARY_LABEL_LEND_REQUEST_NAME; ?>:<br />
					<input class="inputbox" type="text" name="user_name" size="38" maxlength="80" />       
				</td>
				<td>
					<?php echo _MEDIALIBRARY_LABEL_LEND_REQUEST_EMAIL; ?>:<br />
					<input class="inputbox" type="text" name="user_email" size="38" maxlength="80" />      				</td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;
					
				</td>
			</tr>
		</table>                                                        
		<table width="100%" border="0" cellspacing="0" cellpadding="0">  			
			<tr>
				<td>
					<?php echo _MEDIALIBRARY_LABEL_LEND_REQUEST_MAILING; ?>:<br /> 					
					<?php
					 editorArea( 'editor1',  '' , 'user_mailing', '400', '200', '30', '5' ) ;       
					 ?> 				
				</td>
				<td>
				<br />
                                     <p>
	                	<?php echo _MEDIALIBRARY_LABEL_LEND_REQUEST_FROM; ?>:<br />
						<input class="inputbox" type="text" name="lend_from" id="lend_from" size="12" maxlength="10" value="<?php echo date("Y-m-d"); ?>" />
	                	<input type="reset" class="button" value="..." onclick="return showCalendar('lend_from', 'y-mm-dd');" />
					</p>
					<p>
						<?php echo _MEDIALIBRARY_LABEL_LEND_REQUEST_UNTIL; ?>:<br />
						<input class="inputbox" type="text" name="lend_until" id="lend_until" size="12" maxlength="10" value="<?php echo date("Y-m-d"); ?>" />
	                	<input type="reset" class="button" value="..." onclick="return showCalendar('lend_until', 'y-mm-dd');" />
                	</p>
				</td>
			</tr>
		</table>
		<?php
		}
		?>




		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>

		<tr>
			<td width="260">
				<?php		
if ($params->get('show_lendstatus') && $params->get('show_lendrequest') && !$params->get( 'lend_save') && $available){    
				?>
                                <br />
<input type="submit" name="submit" value="<?php echo _MEDIALIBRARY_LABEL_BUTTON_LEND_REQU; ?>" class="button" />		
                                <br /> 						
				<?php
    			} else if ($params->get('show_lendstatus') && $params->get('show_lendrequest') && $params->get( 'lend_save') && $available){  
				?>
<input type="button" class="button" value="<?php echo _MEDIALIBRARY_LABEL_BUTTON_LEND_REQU_SAVE; ?>" onclick="lend_request_submitbutton()" />
				<?php
				}else{ ?>
					&nbsp;
				<?php
				}
				?>
                        </td>                         
			<td align="right">
				<?php
					// 	displays back button
					mosHTML::BackButton ( $params, $hide_js );
				?>
			</td>
		</tr>
		<tr>
<td colspan="2">&nbsp;



                </td>
		</tr>
		</table>

		<?php
		if ( $is_exist_sub_categories )
                {

		?>			
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<?php echo _MEDIALIBRARY_LABEL_FETCHED_SUBCATEGORIES . " : " . $params->get( 'category_name' ); ?>			</div>
		<?php
			HTML_medialibrary::listCategories($params, $categories, $catid, $tabclass , $currentcat);
		}
		if($params->get('show_search')){
		?>
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="50%">
							<?php
								$link = 'index.php?option=com_medialibrary&amp;task=show_search&amp;catid='.
                   $catid. '&amp;Itemid='. $Itemid;
							?>
              <a href="<?php echo sefRelToAbs($link); ?>" 
                class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
		          <img src="./components/com_medialibrary/images/search.gif" alt="?" 
                border="0" align="left"/>     
								&nbsp;<?php echo _MEDIALIBRARY_LABEL_SEARCH; ?>
							</a>
						</td>
						<td width="50%">&nbsp;
							
						</td>
					</tr>
					<tr>
						<td colspan="2">&nbsp;
						</td>
					</tr>
				</table>
			</div>
		<?php
		}
		?>
		</form>
		<?php
	}

//----------------------------------------------------------
  function displayMediaBook( &$media, &$media_type_class, &$params)
  {
    global $medialibrary_configuration,$mosConfig_live_site;
    
    ?>

    <tr>
      <td nowrap="nowrap" width="20%" align="right">       
        <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->title; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_AUTHORS; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->authors; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ISBN; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->isbn; ?>
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_MANUFACTURER; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->manufacturer; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->release_date; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_EDITION; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->edition; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php //echo _MEDIALIBRARY_LANGUAGE_.strtoupper($book->language); 
        echo $media_type_class->language;//old ENGLISH strtoupper($book->language);
        ?>
      </td>
    </tr>
    <?php if($params->get( 'show_price' ) == '1'){ ?>
      <tr>
        <td nowrap="nowrap" align="right">
          <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php echo $media_type_class->price; ?>
        </td>
      </tr>
    <?php } ?>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <img src="./components/com_medialibrary/images/rating-<?php echo $media_type_class->rating; ?>.gif" alt="<?php echo ($media_type_class->rating)/2; ?>" border="0" />&nbsp;
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right" valign="top">
        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
          <?php 
          //for local images
          $imageURL = $media_type_class->imageURL;
          if($imageURL != '' && substr($imageURL,0,4) != "http")
          {
            $imageURL = $mosConfig_live_site . '/'. $media_type_class->imageURL;;
          }

          if($imageURL != ''){
            echo '<img src="'.$imageURL.'" alt="cover" border="0" height="'.$medialibrary_configuration['foto']['high'].'" width="'.$medialibrary_configuration['foto']['width'].'"/>';
          } else{
            echo '<img src="'.$mosConfig_live_site.'/components/com_medialibrary/images/' . _MEDIALIBRARY_NO_PICTURE.'" alt="no-img_eng.gif" border="0" />';
          }?>

<!--************   begin add button 'buy now'   ************************-->

        <?php //show button 'buy now'
         if ( $params->get('show_input_buy_now') )
         {
        ?>

          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          <a href="<?php echo sefRelToAbs($media_type_class->URL);?>" target="blank">
          <img src="<?php echo $mosConfig_live_site;?>/components/com_medialibrary/images/amazon/buy_now.png" alt="Button Buy now" border="0" height="27" width="82" />
          </a>

      <?php   
         }
       ?>
<!--************************   end add button 'buy now'   ******************-->
      </td>
    </tr>
  
    <?php 
      if($params->get( 'show_emedisrequest' ) && $media_type_class->ebookURL != null )  {
  
        $session =& JFactory::getSession();
        $sid = $session->getId();
        $session->set("ssmid",$sid);
        setcookie('ssd',$sid,mktime().time()+60*60*24, "/" );
                                         
    ?>
        <tr>
        <td align="right" >
        <strong><?php echo _MEDIALIBRARY_LABEL_EMEDIA; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
            <td align ="left">  
          <a href="<?php echo sefRelToAbs('index.php?option=com_medialibrary&amp;task=mdownload&amp;id='. $media->id); ?>" target="blank">
            <?php echo _MEDIALIBRARY_LABEL_EMEDIA_DOWNLOAD;?>
          </a>
        </td>
      </tr> 
    <?php       
      }
    ?>
    <?php //lend out?? 
    if( $params->get('show_lendstatus')) {
      $lend = $media->getLend();
      if ($lend == null){
        $help['name']= '';
        $help['until']= '';
        $help['lend']= '';  
      } else {
        $help =  & $lend->getLendTo();
        $help['lend'] = substr($lend->lend_from, 0, 10) . " - ";
        if($lend->lend_until != null){
            $help['lend'] = $help['lend'] . substr($lend->lend_until, 0, 10);
        }
        else {
            $help['lend'] = $help['lend'] . _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL_NOT_KNOWN;
        }               
      }
      ?>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_TO; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php 
              echo $help['name'];           
            ?>
          </td>
        </tr>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php echo $help['lend'] ?>
          </td>
        </tr>
      <?php } 
      ?>      
      <tr>
        <td align="right" valign="top">
          <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php
            echo $media_type_class->comment; 
          ?>
        </td>
      </tr>       
  
    <?php 
  }

//----------------------------------------------------------
  function displayMediaVideo( &$media, &$media_type_class, &$params)
  {
    global $medialibrary_configuration,$mosConfig_live_site;
    
    ?>

    <tr>
      <td nowrap="nowrap" width="20%" align="right">       
        <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->title; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ASIN; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->asin; ?>
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PRODUCER; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->producers; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_DIRECTOR; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->directors; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ACTORS; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->actors; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->release_date; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_STUDIO; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->studio; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_REGION; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->region; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_NUMBER_OF_DISCS; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->number_of_discs; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RUNTIME; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->run_time; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_FORMAT; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->format; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php //echo _MEDIALIBRARY_LANGUAGE_.strtoupper($book->language); 
        echo $media_type_class->language;//old ENGLISH strtoupper($book->language);
        ?>
      </td>
    </tr>
    <?php if($params->get( 'show_price' ) == '1'){ ?>
      <tr>
        <td nowrap="nowrap" align="right">
          <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php echo $media_type_class->price; ?>
        </td>
      </tr>
    <?php } ?>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <img src="./components/com_medialibrary/images/rating-<?php echo $media_type_class->rating; ?>.gif" alt="<?php echo ($media_type_class->rating)/2; ?>" border="0" />&nbsp;
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right" valign="top">
        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
          <?php 
          //for local images
          $imageURL = $media_type_class->imageURL;
          if($imageURL != '' && substr($imageURL,0,4) != "http")
          {
            $imageURL = $mosConfig_live_site . '/'. $media_type_class->imageURL;;
          }

          if($imageURL != ''){
            echo '<img src="'.$imageURL.'" alt="cover" border="0" height="'.$medialibrary_configuration['foto']['high'].'" width="'.$medialibrary_configuration['foto']['width'].'"/>';
          } else{
            echo '<img src="'.$mosConfig_live_site.'/components/com_medialibrary/images/' . _MEDIALIBRARY_NO_PICTURE.'" alt="no-img_eng.gif" border="0" />';
          }?>

<!--************   begin add button 'buy now'   ************************-->

        <?php //show button 'buy now'
         if ( $params->get('show_input_buy_now') )
         {
        ?>

          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          <a href="<?php echo sefRelToAbs($media_type_class->URL);?>" target="blank">
          <img src="<?php echo $mosConfig_live_site;?>/components/com_medialibrary/images/amazon/buy_now.png" alt="Button Buy now" border="0" height="27" width="82" />
          </a>

      <?php   
         }
       ?>
<!--************************   end add button 'buy now'   ******************-->
      </td>
    </tr>
  
    <?php 
      if($params->get( 'show_emedisrequest' ) && $media_type_class->evideoURL != null )  {
  
        $session =& JFactory::getSession();
        $sid = $session->getId();
        $session->set("ssmid",$sid);
        setcookie('ssd',$sid,mktime().time()+60*60*24, "/" );
                                         
    ?>
        <tr>
        <td align="right" >
        <strong><?php echo _MEDIALIBRARY_LABEL_EMEDIA; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
            <td align ="left">  
          <a href="<?php echo sefRelToAbs('index.php?option=com_medialibrary&amp;task=mdownload&amp;id='. $media->id); ?>" target="blank">
            <?php echo _MEDIALIBRARY_LABEL_EMEDIA_DOWNLOAD;?>
          </a>
        </td>
      </tr> 
    <?php       
      }
    ?>
    <?php //lend out?? 
    if( $params->get('show_lendstatus')) {
      $lend = $media->getLend();
      if ($lend == null){
        $help['name']= '';
        $help['until']= '';
        $help['lend']= '';  
      } else {
        $help =  & $lend->getLendTo();
        $help['lend'] = substr($lend->lend_from, 0, 10) . " - ";
        if($lend->lend_until != null){
            $help['lend'] = $help['lend'] . substr($lend->lend_until, 0, 10);
        }
        else {
            $help['lend'] = $help['lend'] . _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL_NOT_KNOWN;
        }               
      }
      ?>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_TO; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php 
              echo $help['name'];           
            ?>
          </td>
        </tr>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php echo $help['lend'] ?>
          </td>
        </tr>
      <?php } 
      ?>      
      <tr>
        <td align="right" valign="top">
          <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php
            echo $media_type_class->comment; 

          ?>
        </td>
      </tr>       
  
    <?php 
  }
//----------------------------------------------------------
  function displayMediaMusic( &$media, &$media_type_class, &$params)
  {
    global $medialibrary_configuration,$mosConfig_live_site;
    
    ?>

    <tr>
      <td nowrap="nowrap" width="20%" align="right">       
        <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->title; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ARTIST; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->artist; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ASIN; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->asin; ?>
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LABEL; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->label; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _RELEASE_DATA; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->release_date; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_NUMBER_OF_DISCS; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->number_of_discs; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_BINDING; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->binding; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_TRACKLIST; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->tracklist; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php //echo _MEDIALIBRARY_LANGUAGE_.strtoupper($book->language); 
        echo $media_type_class->language;//old ENGLISH strtoupper($book->language);
        ?>
      </td>
    </tr>
    <?php if($params->get( 'show_price' ) == '1'){ ?>
      <tr>
        <td nowrap="nowrap" align="right">
          <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php echo $media_type_class->price; ?>
        </td>
      </tr>
    <?php } ?>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <img src="./components/com_medialibrary/images/rating-<?php echo $media_type_class->rating; ?>.gif" alt="<?php echo ($media_type_class->rating)/2; ?>" border="0" />&nbsp;
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right" valign="top">
        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
          <?php 
          //for local images
          $imageURL = $media_type_class->imageURL;
          if($imageURL != '' && substr($imageURL,0,4) != "http")
          {
            $imageURL = $mosConfig_live_site . '/'. $media_type_class->imageURL;;
          }

          if($imageURL != ''){
            echo '<img src="'.$imageURL.'" alt="cover" border="0" height="'.$medialibrary_configuration['foto']['high'].'" width="'.$medialibrary_configuration['foto']['width'].'"/>';
          } else{
            echo '<img src="'.$mosConfig_live_site.'/components/com_medialibrary/images/' . _MEDIALIBRARY_NO_PICTURE.'" alt="no-img_eng.gif" border="0" />';
          }?>

<!--************   begin add button 'buy now'   ************************-->

        <?php //show button 'buy now'
         if ( $params->get('show_input_buy_now') )
         {
        ?>

          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          <a href="<?php echo sefRelToAbs($media_type_class->URL);?>" target="blank">
          <img src="<?php echo $mosConfig_live_site;?>/components/com_medialibrary/images/amazon/buy_now.png" alt="Button Buy now" border="0" height="27" width="82" />
          </a>

      <?php   
         }
       ?>
<!--************************   end add button 'buy now'   ******************-->
      </td>
    </tr>
  
    <?php 
      if($params->get( 'show_emedisrequest' ) && $media_type_class->emusicURL != null )  {
  
        $session =& JFactory::getSession();
        $sid = $session->getId();
        $session->set("ssmid",$sid);
        setcookie('ssd',$sid,mktime().time()+60*60*24, "/" );
                                         
    ?>
        <tr>
        <td align="right" >
        <strong><?php echo _MEDIALIBRARY_LABEL_EMEDIA; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
            <td align ="left">  
          <a href="<?php echo sefRelToAbs('index.php?option=com_medialibrary&amp;task=mdownload&amp;id='. $media->id); ?>" target="blank">
            <?php echo _MEDIALIBRARY_LABEL_EMEDIA_DOWNLOAD;?>
          </a>
        </td>
      </tr> 
    <?php       
      }
    ?>
    <?php //lend out?? 
    if( $params->get('show_lendstatus')) {
      $lend = $media->getLend();
      if ($lend == null){
        $help['name']= '';
        $help['until']= '';
        $help['lend']= '';  
      } else {
        $help =  & $lend->getLendTo();
        $help['lend'] = substr($lend->lend_from, 0, 10) . " - ";
        if($lend->lend_until != null){
            $help['lend'] = $help['lend'] . substr($lend->lend_until, 0, 10);
        }
        else {
            $help['lend'] = $help['lend'] . _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL_NOT_KNOWN;
        }               
      }
      ?>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_TO; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php 
              echo $help['name'];           
            ?>
          </td>
        </tr>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php echo $help['lend'] ?>
          </td>
        </tr>
      <?php } 
      ?>      
      <tr>
        <td align="right" valign="top">
          <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php
            echo $media_type_class->comment;
          ?>
        </td>
      </tr>       
  
    <?php 
  }
//----------------------------------------------------------
  function displayMediaGame( &$media, &$media_type_class, &$params)
  {
    global $medialibrary_configuration,$mosConfig_live_site;
    
    ?>

    <tr>
      <td nowrap="nowrap" width="20%" align="right">       
        <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->title; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_STUDIO; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->studio; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ASIN; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->asin; ?>
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_BINDING; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->binding; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->release_date; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PLATFORM; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php echo $media_type_class->platform; ?>
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <?php //echo _MEDIALIBRARY_LANGUAGE_.strtoupper($book->language); 
        echo $media_type_class->language;//old ENGLISH strtoupper($book->language);
        ?>
      </td>
    </tr>
    <?php if($params->get( 'show_price' ) == '1'){ ?>
      <tr>
        <td nowrap="nowrap" align="right">
          <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php echo $media_type_class->price; ?>
        </td>
      </tr>
    <?php } ?>
    <tr>
      <td nowrap="nowrap" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
        <img src="./components/com_medialibrary/images/rating-<?php echo $media_type_class->rating; ?>.gif" alt="<?php echo ($media_type_class->rating)/2; ?>" border="0" />&nbsp;
      </td>
    </tr>   
    <tr>
      <td nowrap="nowrap" align="right" valign="top">
        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
      </td>
      <td>
          <?php 
          //for local images
          $imageURL = $media_type_class->imageURL;
          if($imageURL != '' && substr($imageURL,0,4) != "http")
          {
            $imageURL = $mosConfig_live_site . '/'. $media_type_class->imageURL;;
          }

          if($imageURL != ''){
            echo '<img src="'.$imageURL.'" alt="cover" border="0" height="'.$medialibrary_configuration['foto']['high'].'" width="'.$medialibrary_configuration['foto']['width'].'"/>';
          } else{
            echo '<img src="'.$mosConfig_live_site.'/components/com_medialibrary/images/' . _MEDIALIBRARY_NO_PICTURE.'" alt="no-img_eng.gif" border="0" />';
          }?>

<!--************   begin add button 'buy now'   ************************-->

        <?php //show button 'buy now'
         if ( $params->get('show_input_buy_now') )
         {
        ?>

          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          <a href="<?php echo sefRelToAbs($media_type_class->URL);?>" target="blank">
          <img src="<?php echo $mosConfig_live_site;?>/components/com_medialibrary/images/amazon/buy_now.png" alt="Button Buy now" border="0" height="27" width="82" />
          </a>

      <?php   
         }
       ?>
<!--************************   end add button 'buy now'   ******************-->
      </td>
    </tr>
  
    <?php 
      if($params->get( 'show_emedisrequest' ) && $media_type_class->egameURL != null )  {
  
        $session =& JFactory::getSession();
        $sid = $session->getId();
        $session->set("ssmid",$sid);
        setcookie('ssd',$sid,mktime().time()+60*60*24, "/" );
                                         
    ?>
        <tr>
        <td align="right" >
        <strong><?php echo _MEDIALIBRARY_LABEL_EMEDIA; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
            <td align ="left">  
          <a href="<?php echo sefRelToAbs('index.php?option=com_medialibrary&amp;task=mdownload&amp;id='. $media->id); ?>" target="blank">
            <?php echo _MEDIALIBRARY_LABEL_EMEDIA_DOWNLOAD;?>
          </a>
        </td>
      </tr> 
    <?php       
      }
    ?>
    <?php //lend out?? 
    if( $params->get('show_lendstatus')) {
      $lend = $media->getLend();
      if ($lend == null){
        $help['name']= '';
        $help['until']= '';
        $help['lend']= '';  
      } else {
        $help =  & $lend->getLendTo();
        $help['lend'] = substr($lend->lend_from, 0, 10) . " - ";
        if($lend->lend_until != null){
            $help['lend'] = $help['lend'] . substr($lend->lend_until, 0, 10);
        }
        else {
            $help['lend'] = $help['lend'] . _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL_NOT_KNOWN;
        }               
      }
      ?>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_TO; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php 
              echo $help['name'];           
            ?>
          </td>
        </tr>
        <tr>
          <td align="right">
            <strong><?php echo _MEDIALIBRARY_LABEL_LEND_FROM_UNTIL; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php echo $help['lend'] ?>
          </td>
        </tr>
      <?php } 
      ?>      
      <tr>
        <td align="right" valign="top">
          <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php
            echo $media_type_class->comment; 
          ?>
        </td>
      </tr>       
  
    <?php 
  }
	
	/**
	 * Displays the media
	 * Lend Status 
	 */
	function displayMedia( &$media, &$media_type_class,& $tabclass, & $params, & $currentcat) 
  {

		global $hide_js,$mainframe, $Itemid, $medialibrary_configuration, $mosConfig_live_site, $mosConfig_absolute_path, $my;						
                
		?>

		<script language="javascript" type="text/javascript">

		function review_submitbutton() {
			var form = document.review;
			// do field validation
			var rating_checked = false;
			for (c = 0;  c < form.rating.length; c++){
				if (form.rating[c].checked){
					rating_checked = true;
				} 
			}
			if (form.title.value == "") {
				alert( "<?php echo _MEDIALIBRARY_INFOTEXT_JS_REVIEW_TITLE; ?>" );
			} else if (form.comment == "") {
				alert( "<?php echo _MEDIALIBRARY_INFOTEXT_JS_REVIEW_COMMENT;?>" );
			} else if (!rating_checked) {				
				alert( "<?php echo _MEDIALIBRARY_INFOTEXT_JS_REVIEW_RATING;?>" );
			} else {
				form.submit();
			}
		}
//*****************   begin add for show/hiden button "Add review" ********************
			function button_hidden( is_hide ) {
				var el  = document.getElementById('button_hidden_review');
				var el2 = document.getElementById('hidden_review');
				if(is_hide){
					el.style.display = 'none';
					el2.style.display = 'block';
				} else {
					el.style.display = 'block';
					el2.style.display = 'none';
				}
			}
//****************   end add for show/hiden button "Add review"   *********************
		</script>


		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
		<?php echo $currentcat->header; ?>
		</div>
		
		<form action="<?php 
       echo        sefRelToAbs("index.php?option=com_medialibrary&amp;task=lend_request&amp;Itemid=$Itemid");?>"
       method="post" name="book">

    <table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>">

    <?php 
      switch ($media->media_type)
      {
        case 'book':
          HTML_medialibrary::displayMediaBook($media, $media_type_class, $params);
          break;
        case 'video':
          HTML_medialibrary::displayMediaVideo($media, $media_type_class, $params);
          break;
        case 'music':
          HTML_medialibrary::displayMediaMusic($media, $media_type_class, $params);
          break;
        case 'game':
          HTML_medialibrary::displayMediaGame($media, $media_type_class, $params);
          break;
      }
    ?>

		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>	
		<tr>
			<td >
			<?php
			if ($params->get('show_lendrequest') && 
        $params->get('show_lendstatus') 
        && $media->fk_lendid == 0){ 
      ?>
				<input type="submit" name="submit" value="<?php echo _MEDIALIBRARY_LABEL_BUTTON_LEND_REQU; ?>" 
         class="button" onclick="document.book.submit()"/>										
			<?php
			}
			?>
			</td>
			<td align="right">
				<?php
				// displays back button
				mosHTML::BackButton ( $params, $hide_js );
				?>
			</td>
		</tr>
		</table>
		<input type="hidden" name="bid[]" value="<?php echo $media->id; ?>" />
		</form>

		<?php //sow the reviews

		if( $params->get('show_reviews')) 
		{
			$reviews = $media->getReviews();	
			?>
        <br />
				<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo _MEDIALIBRARY_LABEL_REVIEWS; ?> 
				</div>
				<table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>">
	
			<?php
			if ($reviews != null && count($reviews) > 0)
			{
				for($m = 0, $n = count($reviews); $m < $n; $m ++ )
				{
				$review = $reviews[$m];
			?>
					<tr>
						<td colspan="3">
							<strong>
								<?php echo $review->title; ?>
							</strong>
						</td>
					</tr>
					<tr>	
						<td>
							<?php echo $review->date; ?>
						</td>				
						<td>
							<?php 
								$help = &$review->getReviewFrom();
								echo $help['name']; 
							?>
						</td>					
						<td width="10">
							<img src="./components/com_medialibrary/images/rating-<?php echo $review->rating; ?>.gif" alt="<?php echo ($review->rating)/2; ?>" border="0" align="right"/>&nbsp;
						</td>
					</tr>
					<tr>
						<td colspan="3">
							<?php echo $review->comment; ?>
						</td>
					</tr>
					<tr>
						<td colspan="3">
							<hr />
						</td>
					</tr>
			<?php
				}
			}
				
			?>
				<tr>
					<td colspan="2">&nbsp;
						
					</td>
				</tr>
			</table>     
			
			<?php 
			if($params->get('show_inputreviews')){
			?>
<!--***********   begin add for show/hiden button "Add review"   ***********************-->
<div id ="button_hidden_review" style="<?php if(isset($_REQUEST['err_msg'] ) ) {echo 'display:none';}?>">
 
<input type="submit" name="submit" value="<?php echo _MEDIALIBRARY_LABEL_BUTTON_ADD_REVIEW; ?>" class="button" onclick="javascript:button_hidden(true)"/>
				
</div>
<!--***********   end add for show/hiden button "Add review"   ************************-->

			<div id="hidden_review" style="<?php if(isset($_REQUEST['err_msg'] ) ) {echo 'display:block';} else {echo 'display:none';} ?>">
				<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<?php echo _MEDIALIBRARY_LABEL_ADDREVIEW; ?>
				</div>
				
				<form action="<?php echo sefRelToAbs("index.php?option=com_medialibrary&amp;task=review&amp;Itemid=". $Itemid); ?>" method="post" name="review">
				<table width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<tr>
						<td colspan="2">
						<?php echo _MEDIALIBRARY_LABEL_REVIEW_TITLE; ?>
						</td>				
					</tr>
					<tr>
						<td colspan="2">					
							<input class="inputbox" type="text" name="title" size="80" value="<?php if ( isset($_REQUEST["title"]) ) {echo $_REQUEST["title"];}?>" />
						</td>
					</tr>
					<tr>
						<td>
							<?php echo _MEDIALIBRARY_LABEL_REVIEW_COMMENT; ?>
						</td>
						<td>
							<?php echo _MEDIALIBRARY_LABEL_REVIEW_RATING; ?>
						</td>
					</tr>
					<tr>
						<td>
							<!--<textarea align= "top" name="comment" id="comment" cols="60" rows="10" style="width:400;height:100;" value="<?php if ( isset($_REQUEST["comment"]) ) {echo $_REQUEST["comment"];}?>"/></textarea>-->
		
       <?php
		    $comm_val = "";
		    if ( isset($_REQUEST["comment"]) )
        {
            $comm_val = $_REQUEST["comment"];
        }
		    editorArea( 'editor1',  $comm_val, 'comment', '410', '200', '60', '10' ) ;    
			 			
      ?>
 
						</td>
						<td width="102">  
							<?php
							$k = 0;
							while($k < 11){
							?>
            <input type="radio" name="rating" value="<?php echo $k;?>"  
              <?php if ( isset($_REQUEST["rating"]) && $_REQUEST["rating"] == $k ) {echo "CHECKED";}?>
               alt="Rating" />
						<img src="./components/com_medialibrary/images/rating-<?php echo $k; ?>.gif" alt="<?php echo ($k)/2; ?>" border="0" /><br />
							<?php	
								$k ++;
							} 
							?>
						</td>
					</tr>				
					<tr>
						<td colspan="2">&nbsp;
							
						</td>
					</tr>

					<tr>
						<td>
							<!-- save review button-->
							<input class="button" type="button" value="<?php echo _MEDIALIBRARY_LABEL_BUTTON_SAVE; ?>" onclick="review_submitbutton()"/>						
						</td>
						<td>
							<!-- hifde review button-->
							<input class="button" type="button" value="<?php echo _MEDIALIBRARY_LABEL_BUTTON_REVIEW_HIDE;?>" onclick="javascript:button_hidden(false);"/>						
						</td>
						<td align="right">							
							<?php
							// displays back button
							// mosHTML::BackButton ( $params, $hide_js );
							?>	
						</td>
					</tr>
					<tr>
						<td colspan="2">&nbsp;
							
						</td>
					</tr>
				</table>
		<input type="hidden" name="fk_mediaid" value="<?php echo $media->id; ?>" />
		<input type="hidden" name="catid" value="<?php echo $media->catid; ?>" />
		</form>


		</div> <!-- end <div id="hidden_review"> -->
<br />
<br />
			<?php
			}
		}
		?>
<?php
	}
	
	
	/**
	* Display links to categories
	*/
	function showCategories( &$params, &$categories, &$catid, &$tabclass , &$currentcat)
  {
		global $hide_js, $Itemid, $acl, $mosConfig_live_site, $my,$mainframe;

    $mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" '.
      ' href="./administrator/components/com_medialibrary/includes/medialibrary.css" ' 
      . 'title="green" />');
?>

		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div>
		<table border="0" cellpadding="4" cellspacing="0" width="100%">
			<tr>
				<td>
					<?php echo $currentcat->descrip; ?>
				</td>     
        <td width="120" align="center">
          <img src="./components/com_medialibrary/images/medialibrary_logo.png" align="right" alt="Medias"/>
        </td>
      </tr>
	  </table>

		<form action="index.php" method="post" name="adminForm">
<?php		
			HTML_medialibrary::listCategories($params, $categories, $catid, $tabclass , $currentcat);
?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="50%">&nbsp;
						
					</td>
					<td width="50%">
						<?php		
							mosHTML::BackButton ( $params, $hide_js ); 
						?>
					</td>
				</tr>
			</table>
		<?php		
		if($params->get('show_search')){
		?>
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="50%">
						<?php
							$link = 'index.php?option=com_medialibrary&amp;task=show_search&amp;catid='. $catid. '&amp;Itemid='. $Itemid;;
					?>
					<a href="<?php echo sefRelToAbs($link); ?>" >
					<img src="./components/com_medialibrary/images/search.gif" alt="Search" border="0" align="left"/>                              &nbsp;<?php echo _MEDIALIBRARY_LABEL_SEARCH; ?>
					</a>
					</td>
					<td width="50%">&nbsp;		
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;
              <br />
					</td>
		</tr>
			</table>
		</div>
		<?php	
		}
//			mosHTML::BackButton ( $params, $hide_js );
                 ?>   
 		</form>


		<?php
}



	
	function listCategories( &$params, $cat_all, $catid, $tabclass , $currentcat) {
		global $Itemid;
	?>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td colspan="2" height="20" width="90%" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _MEDIALIBRARY_LABEL_CATEGORY;?>
			</td>
			<td height="20" width="10%" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _MEDIALIBRARY_LABEL_MEDIA;?> 
			</td>				
		</tr>
		<tr>
			<td colspan="3">
			<?php
			HTML_medialibrary::showInsertSubCategory($catid, $cat_all, $params, $tabclass, $Itemid, 0);
			?>
			</td>
		</tr>
		<tr>
			<td colspan="3">&nbsp;
				
			</td>
		</tr>
		</table>
<?php	
	}
/*
* add Nikolay - ordaSoft
* function for show subcategory
*/
function showInsertSubCategory($id, $cat_all, $params, $tabclass, $Itemid, $deep) {
	global $g_item_count,$medialibrary_configuration ;
	$deep++;
	for ($i = 0; $i < count($cat_all); $i++) {
	    if ( ($id == $cat_all[$i]->parent_id) && ($cat_all[$i]->display == 1) ) {
		$g_item_count++;

		$link = 'index.php?option=com_medialibrary&amp;task=showCategory&amp;catid='. $cat_all[$i]->id .'&amp;Itemid='. $Itemid;
		?>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr class="<?php echo $tabclass[($g_item_count%2)]; ?>">
				<td width="1%">
					<?php
					if ($deep != 1 ) {
					   $jj = $deep;
					   while ($jj--){echo "&nbsp;&nbsp;&nbsp;&nbsp;";}
					   echo "&nbsp;|_";
					}
					?>
				</td>
				<td width="9%">
				<?php
					if ( ($params->get( 'show_cat_pic')) && ($cat_all[$i]->image != "")) {?>
					   <img src="./images/stories/<?php echo $cat_all[$i]->image;?>" alt="picture for subcategory" height="48" width="48" />&nbsp;
				<?php
					} else  {?>
						<img src="./components/com_medialibrary/images/folder.png" alt="picture for subcategory" height="48" width="48" />&nbsp;
					  <?php }?>
				</td>
				<td width="80%">	
					<a href="<?php echo sefRelToAbs( $link ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo $cat_all[$i]->title;?>
					</a>					
				</td>
				<td  align="left" width="10%">				
					<?php if ($cat_all[$i]->medias == '') echo "0";else echo $cat_all[$i]->medias;?>
				</td>
			</tr>
		</table>
		<?php



if($medialibrary_configuration['subcategory']['show']) HTML_medialibrary::showInsertSubCategory($cat_all[$i]->id, $cat_all, $params, $tabclass, $Itemid, $deep);

	    }//end if ($id == $cat_all[$i]->parent_id)
//	    $z = 1 - $z;
	}//end for(...)	
}//end function showInsertSubCategory($id, $cat_all)


function showSearchMedias( $params, $currentcat, $clist , $option)
{
		global $hide_js, $Itemid;
	?>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div>
                      
                  

		<table border="0" cellpadding="4" cellspacing="0" width="100%">
			<tr>				
				<?php

				if($currentcat->img != null && $currentcat->align == 'left')
                                {
				 ?>
				<td>

		                 <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" />
		        	</td>
		         <?php
				}
				?>
				<td width="100%">
				  <?php echo $currentcat->descrip; ?>
				</td>
		         <?php
					if($currentcat->img != null && $currentcat->align == 'right')
                                        {
                                         
				?>
				 <td>
		        	  <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>"  alt = "?"/>
		        	 </td>
		         <?php
				}
				?>
		        </tr>
	       </table>



<form action="<?php echo sefRelToAbs("index.php?option=". $option ."&amp;task=search&amp;Itemid=". $Itemid); ?>" method="post" name="adminForm">


 <table border="0" cellpadding="4" cellspacing="0" width="100%">
   <tr>
				 <td align="right">
				   <?php echo _MEDIALIBRARY_LABEL_SEARCH_KEYWORD; ?>&nbsp;
				 </td>
		        	 <td align="left">
		          	   <input class="inputbox" type="text" name="searchtext" size="20" maxlength="20"/>
		        	 </td>
		               </tr>

				<tr>      
		        	  <td align="right">
				     <?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?>&nbsp;
				  </td>
		        	  <td align="left">
		          	     <?php echo $clist; ?>
		        	  </td>
		               </tr>
			       <tr>      
	<td align="center" colspan="2">
            <input type="submit" name="submit" value="<?php echo _MEDIALIBRARY_LABEL_SEARCH_BUTTON;?>" class="button" />
        </td>       
     </tr>
		    </table>			
			<br />       
			<?php
				mosHTML::BackButton ( $params, $hide_js );
			?>
		</form>
<?php
}



	function showLendRequestThanks( $params, $currentcat){
		global $hide_js, $Itemid;
	?>
	<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
	   <?php echo $currentcat->header; ?>
	</div>
	<table border="0" cellpadding="4" cellspacing="0" width="100%">
			<tr>				
			  <?php
			    if($currentcat->img != null )
                             {
			  ?>
			     <td>

		        	<img src="<?php echo $currentcat->img; ?>" alt="?" />
		             </td>
		        <?php
				}
				?>
			     <td width="100%">
			       <?php echo $currentcat->descrip; ?>
			     </td>
		       
		     </tr>
	    </table>
		<form action="<?php echo sefRelToAbs("index.php?option=com_medialibrary&amp;Itemid=".$Itemid);?>" method="post" name="userForm">
			<table border="0" cellpadding="4" cellspacing="0" width="100%">
		      	<tr>
			   <td colspan="2" align="right">&nbsp;			
			   </td>
		      	</tr>
		      	<tr>
			  <td>
			    <?php
			      //mosHTML::BackButton ( $params, $hide_js );
			     ?>
			  </td>
			  <td>
			   <input type="submit" name="submit" value="<?php echo _MEDIALIBRARY_LABEL_OK; ?>" class="button" />
			  </td>
		      	</tr>

		    </table>			
		</form>
<?php
	}
	
}
?>
